<?php

class Default_Model_DbTable_City extends Zend_Db_Table_Abstract
{
	protected $_name = 'hae_bdd_city';
	protected $_sequence=true;
	protected $_primary='id';
	
	public function getlistcity($countryId)
	{
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
	    if( $countryId == 0 ) // all country 
	    {
	        $select = $this->select();
	        $select->from($this->_name, array("id","name_".$lang." AS name","alias"));
			return $this->fetchAll($select);
	    }
	    else // country by one
	    {
	        try {
	        	$select = $this->select();
	        	$select->from($this->_name, array("id","name_".$lang." AS name","alias"));
	        	$select->where("countryId = ?",$countryId);
	        	return $this->fetchAll($select);
	        }catch (Zend_Exception $e)
	        {
	        	echo $e->getMessage();
	        }
	    }
	}
}

?>